package com.lmj.springcloud.controller;

import com.lmj.springcloud.pojo.Dept;
import com.lmj.springcloud.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @ClassName DeptConsumerController
 * @Date 2021/9/14 16:20
 * @Author 李明杰
 * @Description 问题：无法解决添加add为null的问题
 */
@RestController
public class DeptConsumerController {


    @Autowired
    private DeptClientService service = null;

    @RequestMapping("/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id) {
        return this.service.queryById(id);
    }

    @RequestMapping("/consumer/dept/add")
    public boolean add(@RequestBody(required = false) Dept dept) {
        return this.service.addDept(dept);

    }

    @RequestMapping("/consumer/dept/list")
    public List<Dept> list() {
        return this.service.queryAll();
    }

}
